﻿<?=$this->load->view('include_header',null)?>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li class="current"><a href="<?=site_url('archive/idcard/'.$id)?>" class="report"><?=(empty($id))?"录入新":"编辑"?>客户基本信息</a></li>
				
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<div id="content">
			<div id="box">
			<form id="form" name="form" method="POST" action="<?=site_url('archive/drive_update/'.$cateid)?>">
			<fieldset>
			<legend>行驶证信息 Vehicle License of People's Republic of China</legend>
			
			<label>号牌号码 Plate No.:</label><input type="text" name="register_code" value="<?=@$info->register_code?>" /> <br />
			<label>车辆类型 Vehicle Type:</label><select type="text" name="type" style="background: #FFFFC0;"><option>-</option></select> <br />
			<label>所有人 Owner:</label><input type="text" name="owner" value="<?=@$info->owner?>" /> <br />
			<label>住址 Owner's Address:</label><input type="text" name="address" value="<?=@$info->address?>" /> <br />
			<label>发动机号码 Engine Code:</label><input type="text" name="engine_code" value="<?=@$info->engine_code?>"/> <br />
			<label>车辆识别号 VIN:</label><input type="text" name="chassis_code" value="<?=@$info->chassis_code?>"/> <br />
			<label>品牌型号 Model:</label><input type="text" name="model" value="<?=@$info->model?>"/> <br />
			<label>总质量 Total Weight:</label><input type="text" name="total_weight" value="<?=@$info->total_weight?>"/>kg <br />
			<label>核定载质量 Carry Weight:</label><input type="text" name="carry_weight" value="<?=@$info->carry_weight?>"/>kg <br />
			<label>核定载客 Passengers:</label><input type="text" name="passengers" value="<?=@$info->passengers?>"/>person <br />
			<hr />
			<label>注册登记日期 Register Date:</label><input type="text" name="register_date" id="register_date" value="<?=@$info->register_date?>" onchange="check_date_rules()"/> <br />
			<label>发证日期 Issued Date:</label><input type="text" name="issued_date" id="issued_date" value="<?=@$info->issued_date?>" onchange="check_date_rules()"/> <br />
			<label>发证机关 Issued By:</label><input type="text" name="issued_by" size="40" value="<?=@$info->issued_by?>" /> <br />
			
			<input type="hidden" name="id" value="<?=$id?>" />
			<input id="button1" type="submit" value="提交信息 Continue" onclick="return check_date_rules()"/>
			<input id="button2" type="reset" value="重置 Cancel" />
			</fieldset>
			</form>
			</div>

		</div>
		
		<?=$this->load->view('include_sidebar',array('id'=>$id,'forms'=>$forms))?>
	</div>

	<script type="text/javascript">
    
    function check_date_rules() {
        if(convert_to_date($('#register_date').val()).getTime() >  new Date().getTime()) {
            alert('[注册登记日期]不能大于[当前日期]！');
            return false;
        }   
        if(convert_to_date($('#issued_date').val()).getTime() > new Date().getTime()) {
            $('#birth1').focus();
            alert('[发证日期]不能大于[当前日期]！'); 
            return false;
        }                 
        return true; 
    }
    
	$().ready(function() {
	  $("#form").validate({
		rules: {
			register_code:{
			 required:true
			},
			type:{
			 required:true
			},
			owner:{
			 required:true
			}
		}
	  });
      
      $.datepicker.setDefaults(
            {
            dateFormat: 'dd/mm/yy'
            }
        );
        
		$( "#register_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			showOn: "both",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true

		});
		$( "#issued_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			showOn: "both",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true

		});
        
        get_select_options(f.type, type_arr, '<?=@$info->type?>');   
	});
    
     var f = document.form;
    
    var type_arr = {
        'Sedan' : '轿车',  
        'Compact Sedan' : '紧凑型车',  
        'Sub-compact Car' : '小型车',  
        'Mid-Size Car' : '中型车',  
        'Large Sedan' : '中大型车',  
        'Luxuary Car' : '豪华车',  
        'SUV' : 'SUV', 
        'MPV' : 'MPV', 
        'Roadster/Coupe ' : '跑车', 
        'Truck/ Pick up' : '皮卡  ', 
        'Others' : '其他'
    }

   
    function get_select_options(obj, kv, sv) {
        var arr = [];
        obj.options.length = 1;
        var i = 1;
        var selectedIndex = 0;
        for(var k in kv) {
            if(sv == k)  selectedIndex = i;
            obj.options[i++] = new Option(kv[k]+'-'+k, k);
        }
        obj.options.selectedIndex = selectedIndex;
    }    
	</script>
	
<?=$this->load->view('include_footer',null)?>
